<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8" session="false" %>
<%@ page import="com.atozsoft.commonutil.Constants"%>
<%@page import="java.math.BigDecimal"%>
<%@page import="com.eos.data.datacontext.UserObject" %>
<%@page import="org.gocom.components.coframe.rights.dataset.CapUser"%>	

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- 
  - Author(s): houfy
  - Date: 2016-10-25 11:03:52
  - Description:
-->
<head>
	<%@include file="/common.jsp"%>
	<%@include file="/common/common.jsp"%>
    <%@include file="/coframe/tools/skins/common.jsp"%>
	<title>发起流程一览</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
</head>
<body>
	<div class="search-condition">
	<a href="#" class="searchclose"></a>
		<div class="list">
        	<div id="queryprocessForm">
	        	<table style="width:100%;" class="table">
	            	<tr>
	              		<td class="tit" style="width:120px">
	              			流程名称：
	              		</td>
	              		<td>
	                		<!-- <input id="processname" class="nui-textbox " onEnter='onKeyEnter' name="processname" style="width:200px"/> -->
	                		<input name="criteria._expr[0].processname" class="nui-textbox" style="width:200px" onenter="onKeyEnter"/>
                        	<input class="nui-hidden" name="criteria._expr[0]._op" value="like"/>
                        	<input class="nui-hidden" name="criteria._expr[0]._likeRule" value="all"/>
	                		
	              		</td>
		              	<td class="tit" style="width:120px">
	              		</td>
	              		<td></td>
	              		<td class="tit" style="width:120px">
	              		</td>
	              		<td>
	                		</td>
	              		<td width="20px"></td>
	            	</tr>
          		</table>
          		<table width="100%" border="0" cellspacing="0" cellpadding="0" class="search-btn-area">
					  <tr>
					     <td>
					      	<a class="nui-button" iconCls="icon-search" onclick="search">查询</a>&nbsp;&nbsp;
					      	<a class="nui-button" iconCls="icon-reload" onclick="clear">清空</a>
					     </td>
					  </tr>
		        </table>
        	</div>
      	</div>
    </div>
    <div style="padding:10px 0px 0px 0px;">
		<div class="nui-toolbar" style="border-bottom:0;">
        	<table style="width:100%;">
            	<tr>
		            <td style="width:100%;">
		                <a class="nui-button" iconCls="icon-add" onclick="add()">新增</a>
		            	<a class="nui-button" iconCls="icon-edit" onclick="edit()" id="edit_btn">修改</a>
		            	<a class="nui-button" iconCls="icon-remove" onclick="remove()" id="delete_btn">删除</a>
		            </td>
	            </tr>
	        </table>
    	</div>
    </div>

    <div class="nui-fit">
  		<div id="processDataGrid" class="nui-datagrid" style="width:100%;height:100%;"
  		 url="com.shendong.mis.process.queryProcessStartlist.biz.ext" dataField="datas"
          	sizeList=[10,20,50,100] multiSelect="true" pageSize="20" allowAlternating="true" >
        	<div property="columns">
        		<div type="checkcolumn" headerAlign="center" align="center" >
          		</div>
        		<div field="id" visible="false">ID</div>
          		<div type="indexcolumn" headerAlign="center" align="center">编号
          		</div>
          		<div field="processname" allowSort="true" headerAlign="center">
        			流程名称
          		</div>
          		<div field="businessname" allowSort="true" headerAlign="center" >
        			关联业务
          		</div>
          		<div name="action" width="100" headerAlign="center" align="center" renderer="urlRenderer" cellStyle="padding:0;">
          			操作
          		</div> 
          		<div field="processurl" visible="false">processurl</div>
          		<div field="processid" visible="false">processid</div>
        	</div>
      	</div>
    </div>
    <script>
    	
      	
      	// 清空查询条件
	   function clear(){
			var form = new nui.Form("#queryprocessForm");
			form.reset();
		}
    </script>
	<script type="text/javascript">
    	nui.parse();
    	//跳转方式修改为弹出TAB
    	var postUrl="<%=request.getContextPath()%>/mis/common/postUrl.jsp?";
    	
    	var grid = nui.get("processDataGrid");
    	// 初始数据
    	grid.load();
    	
  		
  		// 回车执行查询
  		function onKeyEnter(e) {
    		search();
  		}
        
    	search();
  		
  		// 查询按钮
  		function search(){
    		var form = new nui.Form("#queryprocessForm");
		    var data = form.getData();//获取表单JS对象数据 
		    //alert(nui.encode(data));
		    //console.log(data);
		    grid.load(data);//datagrid加载数据
  		}
  		
  		//增加员工信息的点击事件
        function add() {
			nui.open({
			url:"<%=request.getContextPath() %>/mis/common/processInput.jsp",
			title:"新增流程",width:620,height:260,
			onload:function(){
				/* var iframe=this.getIFrameEl();
				var data={action:"new"};
				iframe.contentWindow.setFormData(data); */ 
			},
			ondestroy:function(action){
				grid.reload();
			}
			});
        }
         //修改员工信息的点击事件
        function edit() {
            var row = grid.getSelected();

            if (row) {
                nui.open({
                    url:"<%=request.getContextPath() %>/mis/common/processInput.jsp?actionFlg=edit&id="+row.id,
                    title: "编辑流程", width: 620, height: 260,
                    onload: function () {
                    	
                     
                        
                    },
                    ondestroy: function () {
                        grid.reload();
                        
                    }
                });
                
            } else {
                alert("请选中一条记录");
            }
        }
        
         // 删除按钮
        function remove() {
            var rows = grid.getSelecteds();
            if (rows.length > 0) {
            	nui.confirm("确认删除勾选流程信息？","删除确认",function(action){
	            	if(action!="ok") return;
	  				var json = nui.encode({datas:rows});
	                $.ajax({
	                    url: "com.shendong.mis.process.deleteProcessStartlist.biz.ext",
		                type: 'POST',
		                data: json,
		                cache: false,
		                contentType:'text/json',
	                    success: function (text) {
	                    	var returnJson = nui.decode(text);
	                    	//alert(returnJson.resultStr);
							if(returnJson.resultStr == 'SUCCESS'){
								nui.alert("流程删除成功！", "提示");
	                        }
	                        else{
	                        	nui.alert("流程删除失败！", "提示");
                        	}
                        	grid.reload();
	                    },
	                    error: function () {
	                    	nui.alert("流程删除异常！", "提示");
	                    }
	                });
                }); 
            } else {
                nui.alert("请选中一条记录！","提示");
            }
        } 
        
        
  		//各种监听事件
	    $(document).ready(
			function(){
			   //收起查询窗口
			   $(".search-condition .searchclose").click(function(){
			  		$(".search-condition .list").toggle();
					setTimeout("nui.layout()", 10 );
			   });
			}
		);
  		
        // 跳转页面
     	function onUrl(actionFlg,processId,financeId,processInstId,workitemid,title,strurl){ 
			// 跳转页面并传参（post）      
			addDetailTab(actionFlg,processId,financeId,processInstId,workitemid,title,strurl);		 
		}
		
		/*
		* 重新打开一个tab页显示详细页面
		* actionFlg: 操作类型
		* guaranteeletterId: ID
		*/
      	function addDetailTab(actionFlg,processId,financeId,processInstId,workitemid,title,strurl){
      		var url ="<%=request.getContextPath()%>" + strurl + "?actionFlg=processStart"; 
      		
			var params=nui.encode({actionFlg:actionFlg,processId:processId,financeId:financeId,processInstId:processInstId,workitemid:workitemid});
			var tabName = "process_start_menu";
			if(processId != null && processId != ""){
				tabName = tabName + "_" + title;
			}
			window.parent.addtabs(postUrl+"url="+url+"&params="+encodeURIComponent(params),title, tabName); 
      	} 
        
        // 数据链接跳转相关
      	function urlRenderer(e) 
      	{	
      		return "<a class='viewbutton' href='javascript:void()' onclick=onUrl('view','"+e.row.id+"','"+e.row.workitemid+"','','"+e.row.processinstid+"','"+e.row.businessname+"','"+e.row.processurl+"')>发起流程</a>"
      				+ '    <a class="Delete_Button" href="javascript:showWFgraph(\'' + e.row.processid + '\')">流程查看</a> ';
     	}
     	
     	function showWFgraph(processInstId){
	    	var zoomvalue = 1;
	    	nui.open({
	            url: "<%=request.getContextPath()%>/wf/common/showWFGraphbyDefId.jsp?processID=" + processInstId + "&zoomvalue=" + zoomvalue,
		        title: "查看流程",
				width: 700, 
		        height: 635,
		        onload: function() {
		        },
		        ondestroy: function (action) {
					
	             }
		    });
      	}
    </script>
</body>
</html>